<template>
	<view class="content">
		<!-- 图片 -->
		<view>
			<view class="ipts">
				<view class="record">
					<view class="">
						<image src="/static/jilu.png" mode=""></image>
						<span>用户信息</span>
					</view>

				</view>
				<!-- 户号 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>档案号</span>
					</view>
					<span class="place-class">A01978888888888</span>
					<!-- <span class="place-class">{{user_info.house_num}}</span> -->
				</view>
				
				<!-- 户主姓名 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>户主姓名</span>
					</view>
					<span class="place-class">孙铁镑</span>
					<!-- <span class="place-class">{{user_info.realname}}</span> -->
				</view>
				
				<!-- 身份证号 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>身份证号</span>
					</view>
					<span class="place-class">133026196600000000</span>
					<!-- <span class="place-class">{{user_info.ID_num}}</span> -->
				</view>
				
				<!-- 联系方式 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>联系方式</span>
					</view>
					<view class="" style="display: flex;align-items: center;">
						<image src="/static/pagesB/tel.png" mode=""></image>
						<span class="place-class">13888888888</span>
					</view>

					<!-- <span class="place-class">{{user_info.mobile}}</span> -->
				</view>
				
				<!-- 地址 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>地址</span>
					</view>
					<span class="place-class">武强县街关镇康庄村81号</span>
					<!-- <span class="place-class">{{user_info.address}}</span> -->
				</view>
			</view>
			<!-- 第二块 -->
			<view class="ipts">
				<!-- 品牌 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>壁挂炉品牌</span>
					</view>
					<view class="place-class">
						<easySelect class="easySelect"
							style="width:400rpx;height:100%;color: #0000;font-size: 24rpx;color: #fff;text-align: right;"
							:options="options" ref="easySelect" :value="user_info.brand_name" @selectOne="brandChange">
						</easySelect>
					</view>
				</view>
				
				<!-- 实际功率 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>壁挂炉功率</span>
					</view>
					<view class="place-class">
						<easySelect class="easySelect"
							style="width:400rpx;height:100%;color: #0000;font-size: 24rpx;color: #fff;text-align: right;"
							:options="options1" ref="easySelect" :value="user_info.power_name" @selectOne="powerChange">
						</easySelect>
					</view>
				</view>
				
				<!-- 气表号 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>气表号</span>
					</view>
					<input class="item-ipt" type="text" placeholder="请输入"/>
				</view>
				
				<!-- 气表底数 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>气表底数</span>
					</view>
					<input v-model="user_info.meter_base_num" style="font-size: 24rpx;" type="text" value=""
						:placeholder="user_info.meter_base_num" />
				</view>
				

				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>气表照片</span>
					</view>
					<view class="addform-items">
						<view class="" style="position: relative;" v-for="(i,index) in img1">
							<image class="form-img" :src="i" :key="index" @tap="seeimg(index)"></image>
							<image class="delet" src="/static/delet.png" mode="" @tap="deletImg(index)"></image>
						</view>
						<view class="add" @tap="choosefrom">
							<u-icon name="camera" color="#999999" size="28"></u-icon>
						</view>
					</view>
				</view>
				

				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>燃气火点照片</span>
					</view>
					<view class="addform-items">
						<view class="" style="position: relative;" v-for="(i,index) in img2">
							<image class="form-img" :src="i" :key="index" @tap="seeimg2(index)"></image>
							<image class="delet" src="/static/delet.png" mode="" @tap="deletImg2(index)"></image>
						</view>
						<view class="add" @tap="choosefrom2">
							<u-icon name="camera" color="#999999" size="28"></u-icon>
						</view>
					</view>
				</view>
				

				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>资料照片</span>
					</view>
					<view class="addform-items">
						<view class="" style="position: relative;" v-for="(i,index) in img3">
							<image class="form-img" :src="i" :key="index" @tap="seeimg3(index)"></image>
							<image class="delet" src="/static/delet.png" mode="" @tap="deletImg3(index)"></image>
						</view>
						<view class="add" @tap="choosefrom3">
							<u-icon name="camera" color="#999999" size="28"></u-icon>
						</view>
					</view>
				</view>
				
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>其他照片</span>
					</view>
					<view class="addform-items">
						<view class="" style="position: relative;" v-for="(i,index) in img4">
							<image class="form-img" :src="i" :key="index" @tap="seeimg4(index)"></image>
							<image class="delet" src="/static/delet.png" mode="" @tap="deletImg4(index)"></image>
						</view>
						<view class="add" @tap="choosefrom4">
							<u-icon name="camera" color="#999999" size="28"></u-icon>
						</view>
					</view>
				</view>
				
				<view class="supplement">
					<view class="info-item" style="border-bottom: 0;">
						<view class="info-item-left">
							<view class="dot"></view>
							<span>备注</span>
						</view>
						<!-- <span class="place-class">添加备注</span> -->
					</view>
					<view class="explain">
						<textarea v-model="autoText" maxlength="200" auto-height @input="textChange" class="textArea"
							value="" placeholder="添加备注" style="font-size: 24rpx;color: #999;" />
					</view>
					<!-- <view class="suppBottom">
						<view class="danger-img-box">
						</view>
						<view class="num">
							<view class="">{{textNumber}}/200</view>
						</view>
					</view> -->
				</view>
			</view>
			<!-- 上次安检时间 -->
			<view class="ipts">
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>是否安检</span>
					</view>
					<view class="danger-img-box">
						<switch :checked="isChecked" @change="isChecked = !isChecked" style="transform:scale(0.7)" />
					</view>
				</view>
				
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>是否签收《居民用气安全检查结果通知书》</span>
					</view>
					<view class="danger-img-box">
						<view class="danger-img-box">
							<switch :checked="isChecked1" @change="isChecked1 = !isChecked1"
								style="transform:scale(0.7)" />
						</view>
					</view>
				</view>
				
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>是否派发安全宣传资料</span>
					</view>
					<view class="danger-img-box">
						<view class="danger-img-box">
							<switch :checked="isChecked2" @change="isChecked2 = !isChecked2"
								style="transform:scale(0.7)" />
						</view>
					</view>
				</view>
			</view>

			<!-- 跟踪记录 -->
			
		</view>
		<cpimg ref="cpimg" @result="cpimgOk" @err="cpimgErr" :number="1" :fixOrientation="true" :size="500"
			:maxWidth="800" :ql="0.7" type="url" />

	</view>
</template>

<script>
	import cpimg from "@/components/cpimg/cpimg.vue"
	import easySelect from '@/components/easy-select/easy-select'
	export default {
		components: {
			easySelect,
			cpimg
		},
		data() {
			return {
				number:0,
				index: 0,
				user: ['居民用户', '工商业用户'],
				ret: '',
				mysearchIpt: false,
				searchIpt: '',
				searchIpts: '',
				flag: true,
				token: '',
				last_check: {},
				user_info: {},
				textNumber: 0,
				// 品牌数组
				options: [],
				// 功率数组
				options1: [],
				// 品牌id
				brandId: '',
				// 功率id
				powerId: '',
				// 备注
				autoText: '',
				// 气表底数
				meter_base_num: '',
				// 默认显示品牌名
				brandName: '',
				// 默认显示功率
				powerName: '',
				// 气表照片地址
				img1: [],
				img2: [],
				img3: [],
				img4: [],
				// 是否安检
				isChecked: true,
				isCheckedNum: '',
				// 是否签收
				isChecked1: true,
				isCheckedNum1: '',
				// 是否派发
				isChecked2: true,
				isCheckedNum2: '',
				showRecord: true,
				marginBotton1: 100 + 'rpx',
				danger_id: ''
			}
		},
		onShow() {
			uni.getStorage({
				key: 'token'
			}).then(da => {
				this.token = da[1].data;
				this.getBrandList()
			})
			
			uni.getStorage({
				key: 'bztext',
				success: (res) => {
					this.autoText = res.data
				}
			})
			uni.getStorage({
				key: 'img1',
				success: (res) => {
					this.img1 = res.data
				}
			})
			uni.getStorage({
				key: 'img2',
				success: (res) => {
					this.img2 = res.data
				}
			})
			
			uni.getStorage({
				key: 'img3',
				success: (res) => {
					this.img3 = res.data
				}
			})
			uni.getStorage({
				key: 'img4',
				success: (res) => {
					this.img4 = res.data
				}
			})
		},
		onLoad(options) {
			console.log('optionssssssssss', options)
			if (options.type) {
				this.mysearchIpt = true
			}
			if (options.danger_id) {
				this.danger_id = options.danger_id
			}
			
			if (options.socont) {
				this.searchIpt = options.socont;
				uni.getStorage({
					key: 'token'
				}).then(da => {
					console.log(da[1])
					this.token = da[1].data;
					this.searNum()
				})
			}
		},
		methods: {
			PickerChange(e) {
				this.index = e.detail.value
			},
			brandChange(option) {
				console.log(option)
				this.user_info.brand_name = option.label
				this.options.forEach(item => {
					if (item.label == this.user_info.brand_name) {
						this.brandId = item.id
					}
				})
			},
			powerChange(option) {
				this.user_info.power_name = option.label
				this.options1.forEach(item => {
					if (item.label == this.user_info.power_name) {
						this.powerId = item.id
					}
				})
			},
			// 选择图片
			choosefrom() {
				if(this.img1.length<4){
					var _this = this
					uni.chooseImage({
						count: 1,
						sizeType: ['original', 'compressed'],
						sourceType: ['camera', 'album'],
						success: (res) => {
							_this.img1.push(res.tempFilePaths[0])
							
						}
					})
				}else{
					uni.showToast({
						icon:'none',
						title:'上传已达到限制'
					})
				}
				
			},
			// 删除图片
			deletImg(index) {
				this.img1.splice(index,1)
			},
			// 图片预览
			seeimg(index) {
				console.log(index);
				// uni.previewImage({
				// 	urls: this.img1
				// });
				console.log(this.img1);
				uni.previewImage({
					urls:this.img1,
					current:index,
					loop:true
				})
			},
			// 选择图片2
			choosefrom2() {
				if(this.img2.length<4){
					var _this = this
					uni.chooseImage({
						count: 1,
						sizeType: ['original', 'compressed'],
						sourceType: ['camera', 'album'],
						success: (res) => {
							_this.img2.push(res.tempFilePaths[0])
							
						}
					})
				}else{
					uni.showToast({
						icon:'none',
						title:'上传已达到限制'
					})
				}
				
			},
			// 删除图片2
			deletImg2(index) {
				this.img2.splice(index,1)
			},
			// 图片预览2
			seeimg2(index) {
				console.log(index);
				// uni.previewImage({
				// 	urls: this.img1
				// });
				console.log(this.img2);
				uni.previewImage({
					urls:this.img2,
					current:index,
					loop:true
				})
			},
			// 选择图片3
			choosefrom3() {
				if(this.img3.length<4){
					var _this = this
					uni.chooseImage({
						count: 1,
						sizeType: ['original', 'compressed'],
						sourceType: ['camera', 'album'],
						success: (res) => {
							_this.img3.push(res.tempFilePaths[0])
							
						}
					})
				}else{
					uni.showToast({
						icon:'none',
						title:'上传已达到限制'
					})
				}
				
			},
			// 删除图片3
			deletImg3(index) {
				this.img3.splice(index,1)
			},
			// 图片预览3
			seeimg3(index) {
				console.log(index);
				// uni.previewImage({
				// 	urls: this.img1
				// });
				console.log(this.img3);
				uni.previewImage({
					urls:this.img3,
					current:index,
					loop:true
				})
			},
			// 选择图片4
			choosefrom4() {
				if(this.img4.length<4){
					var _this = this
					uni.chooseImage({
						count: 1,
						sizeType: ['original', 'compressed'],
						sourceType: ['camera', 'album'],
						success: (res) => {
							_this.img4.push(res.tempFilePaths[0])
							
						}
					})
				}else{
					uni.showToast({
						icon:'none',
						title:'上传已达到限制'
					})
				}
				
			},
			// 删除图片4
			deletImg4(index) {
				this.img4.splice(index,1)
			},
			// 图片预览4
			seeimg4(index) {
				console.log(index);
				// uni.previewImage({
				// 	urls: this.img1
				// });
				console.log(this.img4);
				uni.previewImage({
					urls:this.img4,
					current:index,
					loop:true
				})
			},
			

			// 选择气表照片

			textChange(e) {
				if (e.detail.cursor >= 200) {
					uni.showToast({
						title: '最多可以输入200个字',
						icon: 'none'
					})
				}
				this.textNumber = e.detail.cursor
			},
			// 获取品牌列表
			getBrandList() {
				let that = this
				that.$request.request({
					url: '/staff/brand_list',
					method: 'POST',
					data: {
						token: that.token
					}
				}).then(res => {
					that.options = res.data.data
				})
				that.$request.request({
					url: '/staff/power_list',
					method: 'POST',
					data: {
						token: that.token
					}
				}).then(res => {
					that.options1 = res.data.data
				})
			},
			// 提交保存
			
			danger() {

				if (this.img1 != '') {
					uni.setStorage({
						key: 'img1',
						data: this.img1
					})
				}

				if (this.img2.length > 0) {
					uni.setStorage({
						key: 'img2',
						data: this.img2
					})
				}

				if (this.img3.length > 0) {
					uni.setStorage({
						key: 'img3',
						data: this.img3
					})
				}

				if (this.img4 != '') {
					uni.setStorage({
						key: 'img4',
						data: this.img4
					})
				}

				if (this.autoText != '') {
					uni.setStorage({
						key: 'bztext',
						data: this.autoText
					})
				}


				uni.navigateTo({
					url: '../securityCheck/dangerReport?id=' + this.last_check.member_id + '&type=' + '5' +
						'&socont=' + this.searchIpt
				})

			},
		}
	}
</script>

<style lang="scss" scoped>
	.addform-items {
		display: flex;
		align-items: center;
	
		.form-img {
			width: 60rpx !important;
			height: 60rpx !important;
			margin-right: 20rpx;
		}
		.delet {
			position: absolute;
			top: -8rpx;
			right: 4rpx;
			width: 28rpx ;
			height: 28rpx ;
			z-index: 10;
		}
	
		.add {
			width: 60rpx;
			height: 60rpx;
			border: 1rpx solid #DDDDDD;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
	.content {
		background: #F1F1F1;
		padding-bottom: 100rpx;
		.header {
			display: flex;
			justify-content: space-between;
			align-items: center;
			// padding: 30rpx 30rpx;
			background-color: #fff;

			.header-right {
				display: flex;
				align-items: center;
				font-size: 24rpx;
				color: #333;
				// margin-right: 20rpx;
				padding: 10rpx 30rpx;

				image {
					width: 32rpx;
					height: 32rpx;
					margin-right: 10rpx;
				}
			}
		}

		.header1 {
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			height: 80rpx;
			width: 100%;
			background-color: #003690;
			padding: 0 30rpx;

			.ipt-box {
				display: flex;
				justify-content: space-between;
				align-items: center;
				box-sizing: border-box;
				padding: 0 20rpx;
				width: 480rpx;
				height: 52rpx;
				background-color: #fff;
				border-radius: 24rpx;

				image {
					width: 32rpx;
					height: 32rpx;
				}
			}

			.header1-right {
				display: flex;
				align-items: center;
				font-size: 28rpx;
				color: #E2ECFB;

				image {
					width: 36rpx;
					height: 36rpx;
				}
			}
		}
		
		.newstyle{
			background: #003690;
			color: #FFFFFF;
		}
		// 气表模块
		.gasmeter{
			display: flex;
			align-items: center;
			// justify-content: space-between;
			// padding: 20rpx 30rpx;
			background: #FFFFFF;
			border-bottom: 1rpx solid #eee;
			.renewal{
				width: 33.3%;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
			}
			
		}

		.searShow {
			width: 360rpx;
			height: 254rpx;
			position: fixed;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);

			image {
				width: 100%;
				height: 100%;
			}
		}

		.dataCont {
			padding-top: 12rpx;
			padding-left: 42rpx;
			padding-right: 30rpx;

			.searTitle {
				font-size: 32rpx;
				font-weight: 600;
				text-align: left;
				color: #333333;
			}

			.searResult {
				display: flex;
				justify-content: space-between;

				.resText {
					font-size: 32rpx;
					font-weight: 400;
					text-align: left;
					color: #777777;
				}

				image {
					width: 36rpx;
					height: 36rpx;
				}
			}
		}

		.ipts {
			background-color: #fff;
			margin-bottom: 20rpx;

			.liaison {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 10rpx 30rpx;

				.left {
					display: flex;
					align-items: center;

					.shuxian {
						width: 8rpx;
						height: 28rpx;
						background: #003690;
						opacity: 1;
						border-radius: 200rpx;
						margin-right: 10rpx;
					}

					.name {
						font-size: 28rpx;
						font-family: Source Han Sans SC;
						font-weight: 500;
						color: #333333;
						margin-right: 10rpx;
					}

					.time {
						font-size: 24rpx;
						font-family: Source Han Sans SC;
						font-weight: 400;
						color: #777777;
					}
				}

				.right {
					display: flex;
					align-items: center;

					image {
						width: 32rpx;
						height: 32rpx;
						margin-right: 10rpx;
					}

					.phone {
						font-size: 24rpx;
						font-family: Source Han Sans SC;
						font-weight: 400;
						color: #555555;
					}
				}
			}
		}

		.info-item {
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			// height: 72rpx;
			width: 100%;
			padding: 0rpx 32rpx;
			height: 100rpx;
			align-items: center;
			background-color: #fff;
			font-size: 24rpx;
			color: #333;
			border-bottom: 1rpx solid #DDDDDD;

			image {
				width: 32rpx;
				height: 32rpx;
			}

			input {
				flex: 1;
				text-align: right;
			}

			.dot {
				width: 8rpx;
				height: 8rpx;
				background-color: #003690;
				border-radius: 50%;
				margin-right: 10rpx;
			}

			.danger-img {
				position: relative;

				.updeletes {
					position: absolute;
					top: -20rpx;
					right: -20rpx;
					width: 40rpx;
					height: 40rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					z-index: 88;

					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.danger-img-box {
				display: flex;

				.danger-img {
					width: 75rpx;
					height: 75rpx;
					// border: 2rpx dashed #eee;
					margin-right: 10rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.danger-img-box2 {
				display: flex;

				.danger-img {
					width: 75rpx;
					height: 75rpx;
					// border: 2rpx dashed #eee;
					margin-right: 10rpx;

					image {
						width: 100%;
						height: 100%;
						opacity: 1;
					}
				}
			}

			.info-item-left {
				display: flex;
				align-items: center;
				font-size: 28rpx;
			}
		}

		.hengxian {
			width: 700rpx;
			height: 2rpx;
			background-color: #eee;
			margin: 20rpx auto;
		}

		.place-class {
			font-size: 28rpx;
			color: #999;
		}
		.item-ipt{
			width: 400rpx;
			text-align: end;
		}

		.btn {
			width: 646rpx;
			height: 80rpx;
			margin: 74rpx auto;
			text-align: center;
			line-height: 80rpx;
			border-radius: 40rpx;
			background-image: linear-gradient(to bottom, #2366D5, #001B48);
			font-size: 32rpx;
			color: #E5EFFE;
		}

		.btns {
			position: fixed;
			bottom: 0;
			display: flex;
			width: 100%;
			z-index: 333;

			.btn1 {
				width: 50%;
				height: 96rpx;
				line-height: 96rpx;
				text-align: center;
				font-size: 24rpx;
			}

			.consel {
				background-color: #e9e9e9;
				color: #777;
			}

			.save {
				background-color: #003690;
				color: #fff;
			}
		}

		.btn:active {
			background: rgba(0, 0, 0, 0.4);
		}

		.zhanwei {
			height: 250rpx;
		}

		.record {
			display: flex;
			align-items: center;
			justify-content: space-between;
			color: #003690;
			font-size: 32rpx;
			padding-top: 20rpx;

			.right {
				width: 394rpx;
				height: 52rpx;
				background: #F2F2F2;
				opacity: 1;
				border-radius: 50rpx;
			}

			image {
				width: 32rpx;
				height: 32rpx;
				margin: 0 20rpx 0 30rpx;
			}

			span {
				font-weight: 700;
			}
		}

		.record-item {
			display: flex;
			justify-content: space-between;
			padding: 10rpx 30rpx;
			border-bottom: 2rpx solid #eee;

			.record-item-left {
				display: flex;
				align-items: center;

				.shu {
					width: 8rpx;
					height: 28rpx;
					background-color: #003690;
					border-radius: 8rpx;
				}

				.title {
					font-size: 32rpx;
					color: #333;
					font-weight: 500;
					margin: 0 10rpx;
				}

				.time {
					font-size: 24rpx;
					color: #777;
				}
			}

			.record-item-right {
				display: flex;
				align-items: center;

				.dianhua {
					width: 28rpx;
					height: 28rpx;
				}

				.zhankai {
					width: 36rpx;
					height: 36rpx;
				}

				.title {
					font-size: 32rpx;
					color: #555;
					font-weight: 500;
					margin: 0 10rpx;
				}
			}
		}

		.supplement {
			background-color: #fff;
			position: relative;
			overflow: hidden;

			.explain {
				.textArea {
					min-height: 142rpx;
					padding: 14rpx 30rpx;
					font-size: 32rpx;
					text-align: left;
					color: rgba(187, 187, 187, 0.84);
				}
			}

			.suppBottom {
				.danger-img {
					position: relative;
					margin-left: 50rpx;
					margin-bottom: 0rpx;
					width: 68rpx;
					height: 68rpx;
					float: left;

					image {
						width: 36rpx;
						height: 36rpx;
						position: absolute;
						left: 50%;
						top: 50%;
						transform: translate(-50%, -50%);
					}
				}

				.num {
					float: right;
					margin-right: 26rpx;
				}
			}
		}
	}
</style>
